<%@page import="java.util.Set"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="js/jquery-1.11.0.js"></script>
<script type="text/javascript">
	$(function(){
		$("select").change(function(){
			change();
		});
		function change(){
			$("#prievew").attr("src",$("select").eq(1).val());
			
		}
		
		change();
		
		function init(){
			//"id_gd":"2","imge_gd":"images/car.jpg","name_gd":"汽车","number_gd":"10","price_gd":"10000"}
			$.post("QueryGoodsServlet",
					{type:1,id:<%=request.getParameter("id")%>},
					function(data){
					$("#gd_id").val(data.id_gd);
					$("#gd_name").val(data.name_gd);
					$("#gd_price").val(data.price_gd);
					$("#gd_number").val(data.number_gd);
					$("#gd_id").val(data.id_gd);
					$("#gd_imge").val(data.imge_gd);
					$("#state").val(data.state);
			},"json");
		}
		
		init();
	});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加商品</title>
</head>
<body>
	<form method="post" action="UpdateGood">
		<input type="hidden" name="type" value="2">
		<input id="gd_id" type="hidden" name="id">
		商品介绍<input id="gd_name" name="name" type="text"><br>
		商品价格<input id="gd_price" name="price"  type="text"><br>
		商品数量<input id="gd_number" name="number"  type="text"><br>
		商品状态
		<select id="state" name="state">
			<option value="1">已上架</option>
			<option value="0">已下架</option>
		</select>
		<br>
		商品图片
		<select id="gd_imge" name="imgeurl">
			<%
				Set<String> set = application.getResourcePaths("/images");
				for(String str:set){
				str = str.replaceFirst("/", "");
			%>
				<option value="<%=str%>"><%=str %></option>
			<%	
				}
			%>
		</select>
		<br>
		<img id="prievew" style="width: 100px ;height: 100px">
		<br>
		<input type="submit" value="更新">
	</form>
</body>
</html>